<%--
  Created by IntelliJ IDEA.
  User: zmjha
  Date: 2020/6/15
  Time: 20:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <title>登陆</title>
</head>
<body>

    用户名：<input type="text" id="userName"><br>
    密  码：<input type="text" id="password"><br>
    <button type="button" onclick="login()">登陆 </button>


</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
    function  login() {
        var userName=$("#userName").val()
        var password=$("#password").val()
        $.ajax({
            url:"login",
            type:"post",
            data:{"userName":userName,"password":password},
            success:function(obj){
                var data=JSON.parse(obj)
                if (data.code==1){
                    alert(data.message)
                }else {
                    location.href="main.jsp"
                }
            }
        })

    }

</script>
</html>
